package com.firewolf.struts.fileupload.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/***
 * 
 * @Description: 用来处理中文乱码问题
 * @Author: 刘兴
 * @Date : 2016年8月25日
 * @package : com.firewolf.struts.filters
 * @Java_Version : 1.7
 * @Version : 2016年8月25日上午11:08:29
 */
public class CharFilter implements Filter {

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2)
			throws IOException, ServletException {
		//设置接收的字符编码
		arg0.setCharacterEncoding("utf-8");
		//继续向下传接
		arg2.doFilter(arg0, arg1);
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}

}
